package org.example.buysystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.buysystem.entity.Good;
import org.example.buysystem.entity.GoodStandard;
import org.example.buysystem.entity.dto.GoodDto;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface GoodMapper extends BaseMapper<Good> {



//    @Select("select * from good")
    List<GoodDto> findallGoods();

    @Select("select * from good_standard where good_id = #{id}")
    List<GoodStandard> getStandardById(Long id);

    @Select("select discount*MIN(price) from good_standard gs,good where"+" good.id=gs.good_id and good.id=#{id}")
    BigDecimal getMinPrice(Long id);

    boolean saleGood(Long goodId, int count, BigDecimal totalPrice);

    @Update("update good set is_delete=1 where id=#{id}")
    void fakeDelete(Long id);
}
